import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src')
        }
    },
    server: {
        port: 3000,
        open: true,
        host: true, // 允许外部访问
        watch: {
            usePolling: true, // 使用轮询监听文件变化
            interval: 1000, // 轮询间隔
        },
        hmr: {
            overlay: true, // 显示错误覆盖层
        },
        proxy: {
            '/baoyang': {
                target: 'http://192.168.10.226:8080', // 这里会自动使用env.js中的配置
                changeOrigin: true,
                secure: true,
                rewrite: (path) => path
            },
            '/productName': {
                target: 'http://192.168.10.226:8080',
                changeOrigin: true,
                secure: true,
                rewrite: (path) => path
            },
            '/container': { // New proxy for container APIs
                target: 'http://192.168.10.226:8080',
                changeOrigin: true,
                secure: true,
                rewrite: (path) => path
            }
        }
    }
}) 